package com.mdxq.order.service;


import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.mdxq.feign.client.UserClient;
import com.mdxq.feign.entity.User;
import com.mdxq.order.entity.Order;
import com.mdxq.order.mapper.OrderMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author WanJl
 * @version 1.0
 * @title OrderService
 * @description
 * @create 2025/1/21
 */
@Service
public class OrderService {
    @Resource
    private OrderMapper orderMapper;

    @Resource
    private UserClient userClient;

    public Order findById(Long id) {
        Order order = orderMapper.selectById(id);
        User user = userClient.findById(order.getUserId());
        order.setUser(user);
        return order;
    }

    /**
     * 正常情况下OrderService的方法是不会被监控的
     * 所以需要添加@SentinelResource注解
     * @return
     */
    @SentinelResource("item")
    public String queryItem(){
        return "查询商品";
    }


}
